package org.zjx.command.service;

import lombok.Getter;
import org.zjx.command.Command;
import org.zjx.core.IWindow;
import org.zjx.dubbo.DubboServiceFactory;
import org.zjx.model.game.Npc;
import org.zjx.service.NpcService;

public class NpcServerCommand extends Command {
    private final String npcName;
    private final int screenId;
    private static NpcService npcService;

    @Getter
    private Npc npc;

    public NpcServerCommand(IWindow targetWindow, String npcName, int screenId) {
        super(targetWindow, false, null);
        this.npcName = npcName;
        this.screenId = screenId;
    }

    @Override
    protected void doExecute() throws Exception {
        if (npcService == null) {
            npcService = DubboServiceFactory.getService(NpcService.class, "npc.service.url");
        }
        npc = npcService.getNpc(npcName, screenId);
    }
}
